<!-- 站点编辑弹窗 -->
<template>
  <el-dialog :destroy-on-close="true" :lock-scroll="false" :visible="visible"
             title="生成二维码" width="750px" @update:visible="updateVisible">
    <el-form ref="form"  label-width="150px">
      <el-form-item label="生成二维码个数：">
        <el-input v-model="count" max="100" min="1" placeholder="请输入个数(1-100)" type="number" />
      </el-form-item>
    </el-form>
    <div slot="footer">
      <el-button @click="cancel">取消</el-button>
      <el-button :loading="loading" type="primary" @click="save">保存</el-button>
    </div>
  </el-dialog>
</template>

<script>

export default {
  name: 'CodeEdit',
  props: {
    visible:Boolean
    // 弹窗是否打开
    // 修改回显的数据
  },
  data() {
    return {
      count: null,
      // 表单数据

      // 提交状态
      loading: false,
      // 是否是修改
      isUpdate: false,
      code_name: ""
    };
  },

  methods: {
    /* 保存编辑 */
    save() {
          this.loading = true;
          // 编辑
          this.$http.post("qr_code_generate", { count: this.count}).then((res) => {
            if (res.data.code === 0) {
              this.loading = false;
              this.count = null
              this.$emit('changeFlag')
              this.$message.success('生成成功')
            } else {
              this.loading = false;
              this.count = null
              this.$emit('changeFlag')
              this.$message.error(res.data.msg);
            }
          }).catch(e => {
            this.loading = false;
            this.$message.error(e.message);
          });
    },
    /* 更新visible */
    updateVisible(value) {
      this.$emit('update:visible', value);
    },
    cancel() {
      this.$emit('changeFlag')
      this.updateVisible(false);
      this.category_name = "";
      this.isUpdate = false;
    },
  }
}
</script>

<style scoped>
.el-autocomplete {
  width: 100%;
}
</style>
